package cn.wh.beans.factory;

import cn.wh.beans.BeansException;
import cn.wh.beans.factory.config.BeanDefinition;

/**
 * @author: wh
 * @create: 2022-08-18 11:20
 * @description
 **/
public abstract class AbstractAutowireCapableBeanFactory extends AbstractBeanFactory {
    @Override
    protected Object createBean(String beanName, BeanDefinition beanDefinition) {
        Object bean;
        try {
            bean = beanDefinition.getBeanClass().newInstance();
        } catch (InstantiationException | IllegalAccessException e) {
            throw new BeansException("Instantiation of bean failed",e);
        }
        addRegistrySingleton(beanName,bean);
        return bean;
    }
}
